package com.atguigu.day16.homework.h1;

import org.junit.Test;

import javax.naming.BinaryRefAddr;
import java.util.Arrays;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/19 20:10
 * @注释
 */
public class HomeWork02 {
    static public int binarySearch(int[] intsArray,int des){

        return Arrays.binarySearch(intsArray, des);
    }
    @Test
    public void test01(){
        //乱序整数数组
        int[] intsArray = {19,14,2,4,5,7,71,8,9,15,11,21,13,3,15};
        //先进行排序,之后才可以进行二分查找
        Arrays.sort(intsArray);
        String string = Arrays.toString(intsArray);
        System.out.println(string);
        //调用方法进行二分查找
        int i = binarySearch(intsArray, 11);
        System.out.println(i);

    }

}
